package com.jiangxiaofei.citycloud.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jiangxiaofei.citycloud.R;
import com.jiangxiaofei.citycloud.bean.GoodListBean;

import java.util.List;

/**
 * @author: JiangXFei
 * @date: 2017/11/15 0015
 * @content:商品分类列表适配器
 */

public class GoodListAdapter extends BaseQuickAdapter<GoodListBean, BaseViewHolder> {
    public GoodListAdapter(int layoutResId, @Nullable List<GoodListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodListBean item) {
        helper.setText(R.id.tv_good_title, item.getTitle());
        helper.setText(R.id.tv_good_price, item.getPrice());
        helper.setText(R.id.tv_good_distance, item.getDistance());
        ImageView imgGoodPhoto = helper.getView(R.id.img_good_photo);
        String[] imgs = item.getImg().split(",");
        Glide.with(mContext)
                .load(imgs[0])
                .apply(RequestOptions.centerCropTransform()
                        .placeholder(R.drawable.ic_no_pic)
                        .error(R.drawable.ic_no_pic)
                )
                .into(imgGoodPhoto);
        helper.setText(R.id.tv_good_date, item.getIssue());
    }
}
